package co.yixiang.modules.shop.domain;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.Data;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import javax.persistence.*;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * @author hupeng
 * @date 2019-10-04
 */
@Entity
@Data
@Table(name = "yx_store_product")
public class YxStoreProduct implements Serializable {

    // 商品id
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Integer id;

    // 商户Id(0为总后台管理员创建,不为0的时候是商户后台创建)
    @Column(name = "mer_id", nullable = false)
    private Integer merId;

    // 商品图片
    @Column(name = "image", nullable = false)
//    @NotBlank(message = "请上传商品图片")
    private String image;

    // 轮播图
    @Column(name = "slider_image", nullable = false)
//    @NotBlank(message = "请上传轮播图")
    private String sliderImage;

    // 商品名称
    @Column(name = "store_name", nullable = false)
//    @NotBlank(message = "请填写商品名称")
    private String storeName;

    // 商品简介
    @Column(name = "store_info", nullable = false)
//    @NotBlank(message = "请填写商品简介")
    private String storeInfo;

    // 关键字
    @Column(name = "keyword")
    private String keyword;

    // 产品条码（一维码）
    @Column(name = "bar_code")
    private String barCode;

    // private Integer cateId;

    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(name = "cate_id")
    @NotFound(action = NotFoundAction.IGNORE)
    private YxStoreCategory storeCategory;

    // 零售价
    @Column(name = "price", nullable = false)
//    @NotNull(message = "价格必填")
//    @Min(value = 0)
    private BigDecimal price;

    // 会员价格
    @Column(name = "vip_price")
    //@NotNull(message = "会员价必填")
    //@Min(value = 0)
    private BigDecimal vipPrice;

    // 市场价
    @Column(name = "ot_price")
    private BigDecimal otPrice;

    // 邮费
    @Column(name = "postage")
    private BigDecimal postage;

    // 单位名
    @Column(name = "unit_name")
    private String unitName;

    // 排序
    @Column(name = "sort")
    private Integer sort;

    // 销量
    @Column(name = "sales")
    private Integer sales;

    // 库存
    @Column(name = "stock")
    private Integer stock;

    // 状态（0：未上架，1：上架）
    @Column(name = "is_show")
    private Integer isShow;

    // 是否热卖
    @Column(name = "is_hot")
    private Integer isHot;

    // 是否优惠
    @Column(name = "is_benefit")
    private Integer isBenefit;

    // 是否精品
    @Column(name = "is_best")
    private Integer isBest;

    // 是否新品
    @Column(name = "is_new")
    private Integer isNew;

    // 产品描述
    @Column(name = "description")
    private String description;

    // 添加时间
    @Column(name = "add_time", nullable = false)
    private Integer addTime;

    // 是否包邮
    @Column(name = "is_postage")
    private Integer isPostage;

    // 是否删除
    @Column(name = "is_del", insertable = false)
    private Integer isDel;

    // 商户是否代理 0不可代理1可代理
    @Column(name = "mer_use")
    private Integer merUse;

    // 获得积分
    @Column(name = "give_integral")
    private BigDecimal giveIntegral;

    // 进货价
    @Column(name = "cost")
    private BigDecimal cost;

    // 秒杀状态 0 未开启 1已开启
    @Column(name = "is_seckill")
    private Integer isSeckill;

    // 砍价状态 0未开启 1开启
    @Column(name = "is_bargain")
    private Integer isBargain;

    // 是否优品推荐
    @Column(name = "is_good")
    private Integer isGood;

    // 虚拟销量
    @Column(name = "ficti")
    private Integer ficti;

    // 浏览量
    @Column(name = "browse")
    private Integer browse;

    // 产品二维码地址(用户小程序海报)
    @Column(name = "code_path")
    private String codePath;

    // 淘宝京东1688类型
    @Column(name = "soure_link")
    private String soureLink;
    /**
     * 是否是投资商品库    0:否    1:是
     */
    @Column(name = "is_stock_invest")
    private Integer isStockInvest;
    /**
     * 数据来源    0:手工添加    1:外部商品库
     */
    @Column(name = "data_source")
    private Integer dataSource;
    /**
     * 产地
     */
    @Column(name = "place")
    private String place;
    /**
     * 是否被认购  0:否    1:是
     */
    @Column(name = "is_invested")
    private Integer isInvested;
    /**
     * 认购成本价(投资成本价)
     */
    @Column(name = "invest_cost")
    private BigDecimal investCost;
    /**
     * 认购金额(投资价)
     */
    @Column(name = "invest_price")
    private BigDecimal investPrice;

    /**
     * 供应销量参考
     *
     * @param source
     */
    @Column(name = "sales_reference")
    private Integer salesReference;
    /**
     * 促销价
     */
    @Column(name = "promote_price")
    private BigDecimal promotePrice;
    /**
     * 保质期
     */
    @Column(name = "keep_date")
    private String keepDate;
    /**
     * 供应商编码
     */
    @Column(name = "supplier_code")
    private String supplierCode;
    /**
     * 供应商名称
     */
    @Column(name = "supplier_name")
    private String supplierName;
    /**
     * 认购商品规则属性unique
     */
    @Column(name = "invest_attr_unique")
    private String investAttrUnique;
    /***保留状态   0:未保留    1:已保留*/
    @Column(name="lock_status")
    private String lockStatus;
    /***保留释放时间 单位:秒*/
    @Column(name="lock_release_time")
    private Integer lockReleaseTime;
    /***保留时间*/
    @Column(name="lock_time")
    private Date lockTime;
    /***保留人*/
    @Column(name="locker")
    private String locker;
    /***保留类型    1: 手工保留   2:认购保留   3:支付保留*/
    @Column(name="lock_type")
    private String lockType;
    /****/
    @Column(name="locker_id")
    private Integer lockerId;
    /***是否上架投资端     0: 否   1:是*/
    @Column(name = "is_invest_on")
    private Integer isInvestOn;
    /***品牌ID**/
    @Column(name = "brand_id")
    private Integer brandId;
    /***品牌名称**/
    @Column(name = "brand_name")
    private String brandName;
    /***产地id**/
    @Column(name = "place_id")
    private Integer placeId;

    /***添加人*/
    @Column(name = "adder")
    private String adder;

    /***仓库存量*/
    @Column(name = "warehouseStock")
    private Integer warehouseStock;

    /***促销开始时间*/
    @Column(name = "promote_begin_time")
    private Date promoteBeginTime;

    /***促销结束时间*/
    @Column(name = "promote_end_time")
    private Date promoteEndTime;

    /***成本价*/
    @Column(name = "purchase_price")
    private BigDecimal purchasePrice;

    /***区域评分*/
    @Column(name = "area_score")
    private Integer areaScore;
    /***季节评分*/
    @Column(name = "season_score")
    private Integer seasonScore;
    /***偏好评分*/
    @Column(name = "like_score")
    private Integer likeScore;
    /***品牌评分*/
    @Column(name = "brand_score")
    private Integer brandScore;
    /***平台评分*/
    @Column(name = "platform_score")
    private Integer platformScore;
    /***风险评分*/
    @Column(name = "risk_score")
    private Integer riskScore;
    /***综合评分*/
    @Column(name = "composite_score")
    private Integer compositeScore;
    /***认购建议*/
    @Column(name = "invest_suggest")
    private String investSuggest;
    /***门店ID*/
    @Column(name = "store_id")
    private String storeId;

    /***门店名称*/
    @Column(name = "store_pname")
    private String storePname;

    /***起订量*/
    @Column(name = "mini_quantity")
    private String miniQuantity;

    /***备注*/
    @Column(name = "remark")
    private String remark;
    /***导入的分类编码*/
    @Column(name = "cate_code")
    private String cateCode;

    /****是否上架商城端  0 否  1 是*/
    @Column(name = "is_mall_on")
    private Integer isMallOn;

    /***是否是商城商品库   0:否    1:是*/
    @Column(name = "is_stock_mall")
    private Integer isStockMall;

    /***认购人姓名*/
    @Column(name = "invest_name")
    private String investName;

    /***线下销量*/
    @Column(name = "store_sales")
    private String storeSales;

    public void copy(YxStoreProduct source) {
        BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
    }
}